<template>
	<view>
		<u-navbar back-text="" title="处理工单" :border-bottom="false">
			<view class="right-navbar" slot="right" @click="navTo('/pages/work/apply-deferment')">申请延期</view>
		</u-navbar>
		<view class="page-content">
			<!-- <view class="time">(超时：<u-count-down :timestamp="timestamp" separator="zh"></u-count-down>)</view> -->
			<view class="time"></view>
			<view class="handler" :style="{height: pageHeight}">
				<view class="handler-title">处理信息</view>
				<view class="title-box">
					<view class="title-label">
						<view class="label">处理视频</view>
					</view>
					<view class="upload-box">
						<u-upload ref="uUploadVideo" :action="action" max-count="5" upload-text="选择视频"></u-upload>
					</view>
				</view>
				<view class="title-box">
					<view class="title-label">
						<view class="label">处理图片</view>
					</view>
					<view class="upload-box">
						<u-upload ref="uUploadImage" :action="action" max-count="5" upload-text="选择图片"></u-upload>
					</view>
				</view>
				<u-form :model="form" ref="uForm" :border-bottom="false" label-position="top">
					<u-form-item label="处理备注">
						<view class="num-text">
							<u-input v-model="form.name" type="textarea" maxlength="100" placeholder="请输入备注" />
							<view class="font-num">0/100</view>
						</view>
					</u-form-item>
				</u-form>
				<u-gap height="16" bg-color="#F8F8F8"></u-gap>
				<view class="hander-info">
					<view class="handler-title">
						<text>报修信息</text>
					</view>
					<view class="title-info">
						<view class="title-txt">维修项目</view>
						<view class="title-value">
							<text>{{ form.project }}</text>
						</view>
					</view>
					<view class="title-info">
						<view class="title-txt">定位</view>
						<view class="title-value">{{ form.position }}</view>
					</view>
					<view class="title-info">
						<view class="title-txt">报修联系人</view>
						<view class="title-value">
							<text>{{ form.repairUser }}</text>
						</view>
					</view>
					<view class="title-info">
						<view class="title-txt">报修人联系方式</view>
						<view class="title-value">
							<text>{{ form.repairPhone }}</text>
						</view>
					</view>
					<view class="title-info">
						<view class="title-txt">截止时间</view>
						<view class="title-value">
							<text>{{ form.endDate }}</text>
						</view>
					</view>
					<view class="title-info">
						<view class="title-txt">维修员</view>
						<view class="title-value">
							<text>{{ form.repairPerson }}</text>
						</view>
					</view>
					<view class="title-info">
						<view class="title-txt">维修员电话</view>
						<view class="title-value">
							<text>{{ form.repairPersonPhone }}</text>
						</view>
					</view>
					<view class="title-info">
						<view class="title-txt">维修内容</view>
						<view class="title-value">
							<text>{{ form.remark }}</text>
						</view>
					</view>
				</view>
				<view class="handler-footer">
					<view class="footer-left" @click="navTo('/pages/work/clock')">
						<image src="/static/icon-sign.png" mode=""></image>
						<text class="sign-text">签到打卡</text>
					</view>
					<text class="footer-right" @click="submitForm">提交</text>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	let systemInfo = uni.getSystemInfoSync();
	export default {
		data() {
			return {
				timestamp: 1186400,
				form: {},
				action: '',
				id: ''
			}
		},
		computed: {
			// 转换字符数值为真正的数值
			navbarHeight() {
				// #ifdef APP-PLUS || H5
				return 44;
				// #endif
				// #ifdef MP
				// 小程序特别处理，让导航栏高度 = 胶囊高度 + 两倍胶囊顶部与状态栏底部的距离之差(相当于同时获得了导航栏底部与胶囊底部的距离)
				// 此方法有缺陷，暂不用(会导致少了几个px)，采用直接固定值的方式
				// return menuButtonInfo.height + (menuButtonInfo.top - this.statusBarHeight) * 2;//导航高度
				let height = systemInfo.platform == 'ios' ? 44 : 48;
				return height;
				// #endif
			},
			pageHeight() {
				return systemInfo.windowHeight - systemInfo.statusBarHeight - this.navbarHeight - 90 + 'px'
			}
		},
		mounted() {
			console.log(this.pageHeight)
		},
		onLoad: function (option) { //option为object类型，会序列化上个页面传递的参数
			this.action = this.vuex_config.baseUrl + '/file/upload'
			this.id = option.id
			this.tabIndex = option.tabIndex
			this.getReportInfo()
		},
		methods: {
			getReportInfo() {
				this.$u.api.reportInfo(this.id).then(res => {
					console.log(res)
					if (res.code === 200) {
						this.form = res.data
					}
				})
			},
			submitForm() {
				let video = this.$refs.uUploadVideo.lists.map(item => {
					return '/file/download?name=' + item.response.data
				})
				let img = this.$refs.uUploadImage.lists.map(item => {
					return '/file/download?name=' + item.response.data
				})
				let params = {
					id: this.id,
					status: 1,
					reStatus: 11
				}
				this.$u.api.reportUpdateStatus(params).then(res => {
					if (res.code === 200) {
						this.$u.toast('提交成功');
						uni.switchTab({
							url: '/pages/work/index'
						})
					}
				})
			},
			navTo(href) {
				uni.navigateTo({
					url: href
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
.page-content {
	position: relative;
	.time {
		width: 100%;
		height: 44rpx;
		background: #fff;
		text-align: center;
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx !important;
		color: #666666 !important;
		line-height: 40rpx;
		font-style: normal;
		::v-deep .u-countdown-time {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx !important;
			color: #666666 !important;
			line-height: 40rpx;
			text-align: center;
			font-style: normal;
		}
		::v-deep .u-countdown-colon {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx !important;
			color: #666666 !important;
			line-height: 40rpx;
			text-align: center;
			font-style: normal;
		}
	}
	.handler {
		margin-top: 16rpx;
		background: #fff;
		padding-top: 30rpx;
		overflow-y: scroll;
		.handler-title {
			font-family: PingFangSC, PingFang SC;
			font-weight: 500;
			font-size: 32rpx;
			color: #333333;
			line-height: 24rpx;
			text-align: left;
			font-style: normal;
			padding-left: 12rpx;
			margin: 0 30rpx 30rpx 30rpx;
			border-left: 6rpx solid #3C7EFF;
		}
		.title-box {
			padding: 24rpx 30rpx;
			.title-label {
				display: flex;
				justify-content: space-between;
				image {
					width: 44rpx;
					height: 44rpx;
				}
			}
			.upload-box {
				::v-deep .u-list-item {
					margin-left: 0;
				}
			}
		}
		.u-form-item {
			padding: 24rpx 30rpx;
		}
		.num-text {
			width: 100%;
			display: flex;
			flex-direction: column;
		}
		.font-num {
			text-align: right;
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #999999;
			line-height: 1;
			text-align: right;
			font-style: normal;
		}
		::v-deep .u-form-item--left__content__label {
			line-height: 1;
		}
		.hander-info {
			padding-top: 30rpx;
			.title-info {
				padding: 24rpx 30rpx;
				.title-txt {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #999999;
					line-height: 24rpx;
					text-align: left;
					font-style: normal;
					margin-bottom: 20rpx;
				}
				.title-value {
					font-family: PingFangSC, PingFang SC;
					font-weight: 400;
					font-size: 32rpx;
					color: #333333;
					line-height: 32rpx;
					text-align: left;
					font-style: normal;
					display: flex;
					align-items: flex-start;
					text {
						line-height: 48rpx;
					}
					image {
						width: 44rpx;
						height: 44rpx;
						margin-left: 16rpx;
					}
				}
				.box-view {
					image {
						width: 152rpx;
						height: 152rpx;
						border-radius: 4px;
						margin-right: 16rpx;
						margin-top: 16rpx;
					}
				}
			}
			.time-box {
				margin: 0 auto;
				display: flex;
				justify-content: center;
				.column-box {
					width: 345px;
					height: 136px;
					padding: 32rpx;
					background: #F1F2F5;
					border-radius: 16rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;
					.step-box {
						display: flex;
						align-items: center;
						.dian {
							width: 16rpx;
							height: 16rpx;
							background: #CECECE;
							border-radius: 50%;
							margin-right: 20rpx;
							display: flex;
							justify-content: center;
							&::after {
								display: inline-block;
								content: " ";
								width: 2rpx;
								height: 136rpx;
								background-color: #ccc;
							}
						}
						.last-dian {
							&::after {
								display: none;
							}
						}
						.step-h3 {
							display: block;
							font-family: PingFangSC, PingFang SC;
							font-weight: 500;
							font-size: 32rpx;
							color: #333333;
							line-height: 44rpx;
							text-align: left;
							font-style: normal;
						}
						.step-p {
							font-family: PingFangSC, PingFang SC;
							font-weight: 400;
							font-size: 28rpx;
							color: #999999;
							line-height: 40rpx;
							text-align: left;
							font-style: normal;
						}
					}
				}
			}
		}
		.handler-footer {
			width: 100%;
			height: 120rpx;
			display: flex;
			justify-content: space-between;
			padding: 16rpx 50rpx;
			position: fixed;
			bottom: 0;
			left: 0;
			background: #fff;
			.footer-left {
				width: 180rpx;
				height: 88rpx;
				background: #F5F5F5;
				border-radius: 16rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				image {
					width: 32rpx;
					height: 32rpx;
					margin-right: 6rpx;
				}
				.text {
					font-family: PingFangSC, PingFang SC;
					font-weight: 500;
					font-size: 28px;
					color: #333333;
					line-height: 40rpx;
					text-align: left;
					font-style: normal;
				}
			}
			.footer-right {
				width: 446rpx;
				height: 88rpx;
				background: #3C7EFF;
				border-radius: 8rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 34rpx;
				color: #FFFFFF;
				line-height: 48px;
				text-align: center;
				font-style: normal;
			}
		}
	}
}
</style>
